package com.itheima.java.ai.langchin4j.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.java.ai.langchin4j.entity.VitalSigns;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface VitalSignsMapper extends BaseMapper<VitalSigns> {
    
    @Select("SELECT * FROM vital_signs WHERE user_id = #{userId} ORDER BY record_time DESC")
    List<VitalSigns> findByUserIdOrderByRecordTimeDesc(Long userId);
    
    @Select("SELECT * FROM vital_signs WHERE user_id = #{userId} ORDER BY record_time DESC LIMIT #{limit}")
    List<VitalSigns> findLatestByUserId(Long userId, int limit);
    
    @Select("SELECT * FROM vital_signs WHERE user_id = #{userId} AND record_time BETWEEN #{startTime} AND #{endTime} ORDER BY record_time DESC")
    List<VitalSigns> selectByUserIdAndDateRange(@Param("userId") Long userId, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime);
}